package com.android.lyricshow.adapter;

import java.util.List;

import com.android.lyricshow.R;
import com.android.lyricshow.bean.SongBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AlbumSongAdapter extends BaseAdapter {
	
	private Context mContext 		= null;
	private List<SongBean> mSongList= null;
	
	public AlbumSongAdapter(Context context, List<SongBean> list){
		mContext	= context;
		mSongList	= list;
	}
	
	@Override
	public int getCount() {
		return mSongList.size();
	}

	@Override
	public Object getItem(int index) {
		return mSongList.get(index);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh;
		
		if(convertView == null){
			convertView = LayoutInflater.from(mContext).inflate(R.layout.album_song_list, null);
			
			vh 			= new ViewHolder();
			vh.tvtitle 	= (TextView)convertView.findViewById(R.id.ablum_song_title);
			
			convertView.setTag(vh);
		}else{
			vh = (ViewHolder)convertView.getTag();
		}
		
		vh.tvtitle.setText(mSongList.get(position).getTitle());
		return convertView;
	}

	static class ViewHolder{
		public TextView tvtitle;
	}
}
